package com.lyf.shop.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.lyf.shop.constant.LoginConstant;
import com.lyf.shop.entity.Order;
import com.lyf.shop.entity.User;
import com.lyf.shop.service.OrderService;
import com.lyf.shop.vo.OrderVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * (Order)表控制层
 *
 * @author makejava
 * @since 2021-12-03 14:46:13
 */
@Controller
@RequestMapping("order")
public class OrderController {
    /**
     * 服务对象
     */
    @Resource
    private OrderService orderService;

    @RequestMapping("toOrder")
    public String toOrder(Model model, HttpSession httpSession) throws JsonProcessingException {
        Order order = orderService.createOrder();
        OrderVo orderVo = orderService.createOrderVo(order);
        model.addAttribute("order",orderVo);
        return "jsp/order";
    }

    @RequestMapping("/allOrder")
    public String list(Model model) {
        Order order=new Order();
        List<Order> list = orderService.queryAll(order);
        model.addAttribute("list", list);
        System.out.println(list);
        return "jsp/lookOrder";
    }
}